<div class="mat-elevation-z1">
  <mat-toolbar>
    <span class="toolbar-title">资产（合并）</span>
    <span class="spacer"></span>
    <mat-checkbox [(ngModel)]="skipSmallAsset" (change)="filterSmall()">仅 &gt; 1美元</mat-checkbox>
    &nbsp;&nbsp;
    <button mat-button (click)="refresh()" [disabled]="processes.refreshing">
      <mat-icon>refresh</mat-icon>
      刷新
    </button>
    <button mat-button (click)="showStructure()" [disabled]="processes.refreshing">
      <mat-icon>donut_large</mat-icon>
      结构
    </button>

    <button mat-button [matMenuTriggerFor]="syncActions">
      <mat-icon>more_vert</mat-icon>
    </button>
    <mat-menu #syncActions="matMenu">
      <button class="flex-button" mat-menu-item (click)="syncAssets()"
              [disabled]="processes.syncAssets">
        <mat-icon>sync</mat-icon>
        同步
      </button>
      <ng-template [ngIf]="skipSmallAsset&&!fetchPriceFailed">
        <button class="flex-button" mat-menu-item (click)="concernAllNonSmall()">
          <mat-icon>star</mat-icon>
          关注全部币种
        </button>
        <button class="flex-button" mat-menu-item (click)="concernPairsWithUSDT()">
          <mat-icon>star</mat-icon>
          关注全部交易对（-USDT）
        </button>
      </ng-template>
    </mat-menu>
  </mat-toolbar>

  <table mat-table class="full-width" matSort matSortActive="holdingValue" matSortDirection="desc">

    <ng-container matColumnDef="index">
      <th mat-header-cell *matHeaderCellDef>#</th>
      <td mat-cell *matCellDef="let row; let index=index">
        {{index + 1}}
      </td>
    </ng-container>

    <ng-container matColumnDef="ccyConcerned">
      <th mat-header-cell *matHeaderCellDef mat-sort-header start="desc">
        <mat-icon>star_outline</mat-icon>
      </th>
      <td mat-cell *matCellDef="let row">
        <mat-icon class="clickable" [class.favorite]="row.ccyConcerned" (click)="toggleCcyConcern(row)">
          {{row.ccyConcerned ? 'star' : 'star_outline'}}
        </mat-icon>
      </td>
    </ng-container>

    <ng-container matColumnDef="ccy">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>币种</th>
      <td mat-cell *matCellDef="let row">
        <span class="ccy-logo-code clickable" (click)="showCcyInfo(row)">
          <img class="ccy-logo" [src]="CoinLogoPath(row.ccy)" alt="">
          <span class="ccy-code">{{row.ccy}}</span>
        </span>
      </td>
    </ng-container>

    <ng-container matColumnDef="ex">
      <th mat-header-cell *matHeaderCellDef>交易所</th>
      <td mat-cell *matCellDef="let row">{{row.exs.join(', ')}}</td>
    </ng-container>

    <ng-container matColumnDef="holding">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>持有量</th>
      <td mat-cell *matCellDef="let row"
          [matTooltip]="holdingTooltip(row)"
          matTooltipShowDelay="200"
          matTooltipHideDelay="200"
          matTooltipClass="multi-lines-tooltip">{{row.holding | money}}</td>
    </ng-container>

    <ng-container matColumnDef="frozen">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>（其中）冻结</th>
      <td mat-cell *matCellDef="let row"
          [matTooltip]="frozenTooltip(row)"
          matTooltipShowDelay="200"
          matTooltipHideDelay="200"
          matTooltipClass="multi-lines-tooltip">{{row.frozen | money}}</td>
    </ng-container>

    <ng-container matColumnDef="price">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>现价（美元）</th>
      <td mat-cell *matCellDef="let row">{{row.price | money}}</td>
    </ng-container>

    <ng-container matColumnDef="holdingValue">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>折美元</th>
      <td mat-cell *matCellDef="let row"
          [matTooltip]="holdingValueTooltip(row)"
          matTooltipShowDelay="200"
          matTooltipHideDelay="200"
          matTooltipClass="multi-lines-tooltip">{{row.holdingValue | moneysum}}</td>
    </ng-container>

    <ng-container matColumnDef="frozenValue">
      <th mat-header-cell *matHeaderCellDef mat-sort-header>冻结（折美元）</th>
      <td mat-cell *matCellDef="let row"
          [matTooltip]="frozenValueTooltip(row)"
          matTooltipShowDelay="200"
          matTooltipHideDelay="200"
          matTooltipClass="multi-lines-tooltip">{{row.frozenValue | moneysum}}</td>
    </ng-container>

    <ng-container matColumnDef="actions">
      <th mat-header-cell *matHeaderCellDef></th>
      <td mat-cell *matCellDef="let row" align="end">
        <button mat-button (click)="showPairsAsBase(row)">
          <mat-icon>sync_alt</mat-icon>
          交易对
        </button>
        <button mat-button (click)="showOrders(row)">
          <mat-icon>list</mat-icon>
          订单
        </button>
      </td>
    </ng-container>

    <ng-container matColumnDef="footer">
      <th mat-header-cell *matFooterCellDef colspan="9" class="sum-row">
        共持有（折美元）：<span class="sum-amount">{{holdingValueSum | moneysum}}</span> &nbsp;&nbsp;&nbsp;&nbsp;
        冻结（折美元）：<span class="sum-amount">{{frozenValueSum | moneysum}}</span>
      </th>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
    <tr mat-footer-row *matFooterRowDef="['footer']"></tr>
  </table>

</div>

<p>&nbsp;</p>
